<template>
    <div class="sm-cs-topTable">
        <el-table
        ref="receiveTable"
        size="mini"
        :data="resData"
        style="width: 100%"
        height="190"
        highlight-current-row
        @selection-change="handleSelectionChange"
        >
        <el-table-column type="selection" width="40"> </el-table-column>
        <el-table-column type="index" label="序号" width="50" :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="workbinCode" label="缓存箱编码"   :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="toolCode" label="工作包编码"   :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="itemCode" label="图号/型号"  :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="itemQty" label="需求数量"  :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="matchQty" label="需要配套数量"  :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="itemType" label="物料类型"  :show-overflow-tooltip="true"> </el-table-column>
        <el-table-column prop="packageCode" label="工作包编码"  :show-overflow-tooltip="true"> </el-table-column>
        <!-- <el-table-column prop="aoCode" label="AO编码"   :show-overflow-tooltip="true"> </el-table-column> -->
      </el-table>
        <!-- 分页 -->
        <el-pagination
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="pageNumber"
            :page-sizes="[1,10,20,50,100]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="totalCount">
        </el-pagination>
    </div>
</template>
<script>
import { smSpmLastTableData } from "@/utils/api.js";
export default {
    name:"SmCsTopTable",
    data(){
        return{
             // 当前页数
            pageNumber: 1,
            // 数据总个数
            totalCount: 0,
            // 返回的数据数组
            resData: [],
            // 每页数据个数
            pageSize: 20,
            // 确认列表高亮参数
            stableIndex: 0,
            topLastInfo:''
        }
    },
    methods:{
        // 分页---每页条数
        handleSizeChange(val){
            this.pageSize = val
            smSpmLastTableData({
                msTaskAoId:this.topLastInfo,
                pageParameter: {
                    rows: this.pageSize,
                    page: this.pageNumber
                },
                }).then((res) => {
                    console.log('分拣管理mid表',res)
                    this.resData = res.data.responseBody.result;
                    this.totalCount = res.data.responseBody.pageParameter.totalCount;
                });
        },
        // 分页---页数
        handleCurrentChange(val) {
            this.pageNumber = val;
            smSpmLastTableData({
                    msTaskAoId:this.topLastInfo,
                    pageParameter: {
                        rows: this.pageSize,
                        page: this.pageNumber
                    },
                }).then((res) => {
                    console.log('分拣管理mid表',res)
                    this.resData = res.data.responseBody.result;
                    this.totalCount = res.data.responseBody.pageParameter.totalCount;
                });
        },
        handleSelectionChange(val){
            this.$bus.$emit("matchInfo",val);
        }
    },
    mounted() {
         // 接收Top表给Last表的msTaskAoId 进行查数据
        this.$bus.$on('smCsTopLastInfo',(e)=>{
            this.topLastInfo = e
                smSpmLastTableData({
                    searchParams:{
                        msTaskAoId:this.topLastInfo
                    },
                    pageParameter: {
                        rows: this.pageSize,
                        page: this.pageNumber
                    },
                }).then((res) => {
                    console.log('工艺更改分拣下表',res)
                    this.resData = res.data.responseBody.result;
                    this.totalCount = res.data.responseBody.pageParameter.totalCount;
                });
        })
            
        
  }
}
</script>
<style scoped>
.sm-cs-topTable {
    text-align: center;
}
</style>